package net.chrone.quickpayapi.util;




import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;

/**
 * xml和java bean互转工具类
 * @author Jerry
 * @date 2015.08.11
 */
public class Object2Xml {

	public static String object2xml(Object object){
		XStream xstream = new XStream(new DomDriver());
		xstream.alias("xml",object.getClass());
		return xstream.toXML(object);
	 }
	 
	 public static Object xml2Object(String xml,Class classname){
		 XStream xstream = new XStream(new DomDriver());
		 xstream.processAnnotations(classname);
		 return xstream.fromXML(xml);
	 }
	 
}
